package com.mianyang.zhangsan.common.util;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class DebugUtils {

    public static Map<String, Object> toMap(Object bean) {
        Map<String, Object> map = new HashMap<>();
        if (bean == null) {
            return map;
        }
        Field[] fields = bean.getClass().getDeclaredFields();
        try {
            for (Field field : fields) {
                String key = field.getName();
                Object value = field.get(bean);
                map.put(key, value);
            }
        } catch (IllegalAccessException e) {
            // do nothing
        }
        return map;
    }
}
